import os
from django.conf.urls.defaults import *
from django.contrib import admin
from django.views.generic.simple import direct_to_template
from django.contrib.auth.views import password_change, password_change_done

from online_shop.users.views import *
from online_shop.products.views import *
from online_shop.cart.views import *
from online_shop.orders.views import *
from online_shop.employees.views import *
from online_shop.captchas.views import *


# Uncomment the next two lines to enable the admin:
# from django.contrib import admin
# admin.autodiscover()

site_media = os.path.join(
  os.path.dirname(__file__), 'site_media'
)
upload =  os.path.join(
  os.path.dirname(__file__), 'upload'
)

urlpatterns = patterns('',
    # User
    #(r'^user/(\w+)/$', user_page),
    (r'^user/check/login/$', user_check_login),
    (r'^login/$', 'django.contrib.auth.views.login'),
    (r'^logout/$', logout_page),
    (r'^register/$', register_page),
    (r'^user_panel/$',user_panel_main),
    (r'^user_panel/account_management/personal_info/$', modify_personal_info),
    (r'^user_panel/account_management/change_password/$', password_change, {'template_name': 'User_panel/Account_Management/password.html'}),
    (r'^user_panel/account_management/change_password/done/$', password_change_done, {'template_name': 'User_panel/user-panel-main.html'}),
    (r'^user_panel/account_management/delivery_address/$', modify_delivery_address),
    (r'^user_panel/my_comments/$', comments_and_replys),
    (r'^user_panel/goods/bought_goods/(\w+)/$', bought_goods),
    (r'^user_panel/goods/favourite_goods/(\w+)/$', favourite_goods),
    (r'^user_panel/goods/uncomment_goods/$', uncomment_goods_list),
    
    # Cart
    (r'^cart/$', show_cart),
    (r'^cart/checkAddress/$', cart_check_address),
    (r'^cart/confirmation/(?P<address_id>\d+)/$', cart_confirmation),
    (r'^cart/payment/$', cart_payment),
    (r'^modify_cart/$', modify_cart),
    
    #product
    (r'^$', main_page),
    (r'^products/(?P<product_id>\d+)/$', product_page),
    (r'^products/add_to_cart/$', product_to_cart),
    #(r'^products/comment/(?P<order_details_id>\d+)/$', product_comment),
    (r'^search/$',search_page),
    (r'^get/subcategory/(?P<category_value>\w+)/$', ajax_fetch_subcategory_by_category),
    (r'^favourite/(?P<product_id>\d+)/$', favourite_product_store_up),
    (r'^favourite/delete/$', favourite_product_del),
    (r'^products/comment_votes/$', add_comment_votes),
    (r'^products/comment/reply/(\d+)/$', comment_reply),
    
    #order
    (r'^order/(?P<order_id>\d+)/makeCommentAndRate/$',make_comment_and_rate_page),
    (r'^payment/success/$', payment_success),
    (r'^order/display/$', show_orders),
    (r'^order/display/details/(\d+)/$', show_order_details),
    (r'^order/arrived/$', shipped_to_arrived),
    (r'^order/filter/(\w+)/$', order_filter),
    (r'^order/(?P<order_id>\d+)/makeCommentAndRate/add/(?P<o_detail_id>\d+)/$',ajax_add_new_comment_and_rate),
    
    
    # Uncomment the admin/doc line below to enable admin documentation:
    # (r'^admin/doc/', include('django.contrib.admindocs.urls')),
    
    #employee
    (r'^employee/$',employee_main_page),
    (r'^employee/login/$',employee_login),
    (r'^employee/logout/$',employee_logout),
    (r'^employee/account/$',employee_account),
    (r'^employee/account/password/$',employee_account_password),
    
    #product managment
    (r'^employee/products/$',employee_admin_products_list),
    (r'^employee/products/add/$',employee_admin_product_add),
    (r'^employee/products/edit/(?P<product_id>\d+)/$',employee_admin_product_edit),
    (r'^employee/products/edit/(?P<product_id>\d+)/delete/$',employee_admin_product_delete),
    (r'^employee/products/inventory/(?P<product_id>\d+)/$',inventory_manage),
    (r'^employee/products/category/$',category_manage),
    (r'^employee/products/category/add$',category_add),
    (r'^employee/products/category/edit/(?P<category_id>\d+)/$',category_edit),
    (r'^employee/products/category/delete/(?P<category_id>\d+)/$',category_delete),
    (r'^employee/products/subcategory/add$',subcategory_add),
    (r'^employee/products/subcategory/edit/(?P<subcategory_id>\d+)/$',subcategory_edit),
    (r'^employee/products/subcategory/delete/(?P<subcategory_id>\d+)/$',subcategory_delete),
    
    #order management
    (r'^employee/orders/$',employee_admin_orders_list),
    (r'^employee/orders/manage/(?P<order_id>\d+)/$',employee_admin_order_manage),
  
    #user management
    (r'^employee/users/$',employee_admin_users_list),
    (r'^employee/users/manage/(?P<user_id>\d+)/$',employee_admin_user_manage),
    
    

    # Uncomment the next line to enable the admin:
    (r'^admin/', include(admin.site.urls)),
    
    # Captcha
    url(r'^(?P<id>\w+)/$', captcha_image, name='captcha_image'),
    
    # Site media
    (r'^site_media/(?P<path>.*)$', 'django.views.static.serve',{'document_root': site_media}),
    (r'^upload/(?P<path>.*)$', 'django.views.static.serve',{'document_root': upload}),
)
